package com.changsha.jacocotest.controller;

import com.changsha.jacocotest.service.TestService1;
import com.changsha.jacocotest.service.TestService2;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api("成绩管理")
@Slf4j
@RequestMapping("/admin")
@RestController
public class AdminController {

    private TestService1 testService1;
    private TestService2 testService2;
    public AdminController(TestService1 testService1, TestService2 testService2){
        this.testService1 = testService1;
        this.testService2 = testService2;
    }

    @GetMapping("/avg")
    @ApiOperation("获取平均分")
    public double getAvgScore(){
        return testService2.getAvgScore();
    }

    @GetMapping("/mid")
    @ApiOperation("获取中位数")
    public double getMidScore(){
        return testService2.getMidScore();
    }

    @GetMapping("/score")
    @ApiOperation("获取学生成绩")
    public int getScore(String name){
//        return testService1.findScore(name);
        return 0;
    }

    @GetMapping("/teacher")
    @ApiOperation("获取老师")
    public String getTeacher(String name1, String name2){
        return testService1.findTeacher(name1, name2);
    }

    @GetMapping("/calculate")
    @ApiOperation("计算")
    public int calculate(int a, int b){
        return testService1.calculate(a, b);
    }


}
